package com.example.doubao_ai_demo.controller;

import com.example.doubao_ai_demo.request.LoginInfoRequest;
import com.example.doubao_ai_demo.res.LoginResultRes;
import com.example.doubao_ai_demo.service.WxLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private WxLoginService wxLoginService;

    @PostMapping("/typeWxLogin")
    public LoginResultRes wxLogin(@RequestBody LoginInfoRequest request) {
        System.out.println(request);
        String code = request.getCode();
        String token = wxLoginService.wxLogin(code);
        return new LoginResultRes(200, token);
    }
}
